package com.example.c_input;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo1CopyFile {
    public static void main(String[] args) {
        try {
            FileInputStream fis = new FileInputStream("D:\\java_project\\test_file\\haha\\heihei\\1.jpg");
            FileOutputStream fos = new FileOutputStream("D:\\java_project\\test_file\\haha\\heihei\\da.jpg");
            byte[] bytes = new byte[1024];
            int len;
            while ((len=fis.read(bytes)) != -1) {
                fos.write(bytes, 0, len);
            }

//            关掉流的习惯，先开的流后关
            fos.close();
            fis.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
